import {debounce} from "./utils";

export const itemImgListenerMixin = {
  data() {
    return {
      itemImageListener: null
    }
  },
  mounted() {
    const refresh = debounce(this.$refs.scroll.refresh, 200)
    this.itemImageListener = () => {refresh()}
    this.$bus.$on('itemImgLoad', this.itemImageListener)
  }
}

import BackTop from "../components/content/backTop/BackTop";
//回到顶部按钮的相同代码的抽取
export const backTopMixin = {
  components: {
    BackTop
  },
  data() {
    return {
      isShowBackTop: false
    }
  },
  methods: {
    BackTop() {
      //500毫秒回到 x=0，y=0 的位置(点击按钮回到顶部)
      this.$refs.scroll.scrollTo(0, 0, 500)
    }
  }
}
